package polymorphism;

public class Test {
    public static void main(String[] args) {
        //1.产生对象
        Animal animal=new Animal("动物",0);
        Animal dag=new Dog("修狗",0);
        Animal cat=new Cat("修猫",0);

        //2.方法参数传递
        fun(animal,"食物");
        fun(dag,"狗粮");
        fun(cat,"猫粮");

        //3.方法返回值
        Animal animal1=test();
        animal1.eat("狗粮");
    }

    public static Animal test(){
        return new Dog("二哈",0);
    }
    public static void fun(Animal animal,String food){
        animal.eat(food);
    }
}
